package yf.mall.controller;

import java.util.List;

import com.yf.annotation.IgnoreAuth;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import yf.mall.entity.AccCardEntity;
import yf.mall.service.AccCardService;
import com.yf.response.R;


/**
 * 银行卡Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Fri Jul 10 10:01:37 CST 2020
 */
@RestController
@RequestMapping("/acc/card")
public class AccCardController {
    @Autowired
    private AccCardService accCardService;

    /**
     * 列表银行卡
     */
    @SysLog("查看银行卡")
    @RequestMapping("/list")
    @RequiresPermissions("acc:card:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<AccCardEntity> accCardList = accCardService.queryList(params);
        return R.ok(new PageInfo(accCardList));
    }

    /**
     * 查看银行卡
     */
    @SysLog("查看银行卡")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("acc:card:info")
    public R info(@PathVariable("id") Long id) {
        AccCardEntity accCard = accCardService.get(id);

        return R.ok(accCard);
    }

    /**
     * 保存银行卡
     */
    @SysLog("保存银行卡")
    @RequestMapping("/save")
    @RequiresPermissions("acc:card:save")
    public R save(AccCardEntity accCard) {
        accCardService.save(accCard);

        return R.ok(accCard);
    }

    /**
     * 修改银行卡
     */
    @SysLog("修改银行卡")
    @RequestMapping("/update")
    @RequiresPermissions("acc:card:update")
    public R update(AccCardEntity accCard) {
        accCardService.update(accCard);

        return R.ok(accCard);
    }

    /**
     * 删除银行卡
     */
    @SysLog("删除银行卡")
    @RequestMapping("/delete")
    @RequiresPermissions("acc:card:delete")
    public R delete(Long[]ids) {
        accCardService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有银行卡
     */
    @SysLog("所有银行卡")
    @RequestMapping("/all")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<AccCardEntity> accCardList = accCardService.queryList(params);

        return R.ok(accCardList);
    }

    /***********自定义开始***********/
}
